Back
 
Special thanks to Michael McCaffrey for his great contributions!

;;; Start here. Complete working "Smart" drone. ;;;
author Michael McCaffrey
name S Turn

Main:
move forward
if bump barrier then goto Barrier
goto Main
 

Barrier:
assign vr 0
math vs = #cur_head * 2 + 1
if value ~vs > 7 then math vs = ~vs - 8
scan position ~vs
if value #scan <> 0 then math vr = ~vr + 1

math vs = #cur_head * 2 + 5
if value ~vs > 7 then math vs = ~vs - 8
scan position ~vs
if value #scan <> 0 then math vr = ~vr + 2

if value ~vr = 0 then goto Random_Turn
if value ~vr = 1 then turn left
if value ~vr = 2 then turn right
if value ~vr = 3 then move backward
if value ~vr = 3 then goto Barrier

goto Main
 

Random_Turn:
generate random
if value #random < 3 then turn right
if value #random > 2 then turn left
goto Main